import {reqBannerList, reqCategoryList, reqFloorList} from "../../api/index";

export default ({
    namespaced: true,
    state: {
        // 三级联动数据
        categoryList: [],
        //轮播图虚拟数据
        bannerList: [],
        //floor轮播图组件数据
        floorList: []
    },
    mutations: {
        CATEGORYLIST(state, categoryList) {
            state.categoryList = categoryList.slice(0, 16)
        },
        //
        GETBANNERLIST(state, value) {
            state.bannerList = value
        },
        //floor轮播图组件
        GETFLOORLIST(state, value) {
            state.floorList = value
        }
    },
    actions: {
        //三级联动组件
        async categoryList({commit}) {
            let res = await reqCategoryList();
            if (res.code == 200) {
                commit('CATEGORYLIST', res.data)
            }
        },
        //轮播图组件
        async getBannerList({commit}) {
            let a = await reqBannerList();
            if (a.code == 200) {
                commit('GETBANNERLIST', a.data)
            }
        },
        // floor轮播图组件
        async getFloorList({commit}) {
            let b = await reqFloorList();
            if (b.code == 200) {
                commit('GETFLOORLIST', b.data)
            }
        }
    },

})